package xkp.lesson.dao;

import xkp.lesson.entity.JobInfo;
import xkp.lesson.entity.UserInfo;
import xkp.lesson.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class JobInfoDao implements BaseDao<JobInfo> {
    @Override
    public boolean insert(JobInfo jobInfo) throws SQLException, ClassNotFoundException {
        return false;
    }

    @Override
    public boolean deleteById(int id) throws SQLException, ClassNotFoundException {
        return false;
    }

    @Override
    public boolean update(JobInfo jobInfo) throws SQLException, ClassNotFoundException {
        return false;
    }

    @Override
    public List<JobInfo> selectAll() throws SQLException, ClassNotFoundException {
        return null;
    }

    @Override
    public JobInfo selectById(int id) throws SQLException, ClassNotFoundException {
        return null;
    }

    @Override
    public int batchInsert(List<JobInfo> jobInfoList) throws SQLException, ClassNotFoundException {
        Connection connection = JDBCUtils.openConn();
        String sql = "insert into job_info (job_id,job_name,job_area,job_Company," +

                "job_Salary) values (?,?,?,?,?)";
        PreparedStatement statement = connection.prepareStatement(sql);
        for(JobInfo jobInfo:jobInfoList){
            statement.setString(1,jobInfo.getJobId());
            statement.setString(2,jobInfo.getJobName());
            statement.setString(3,jobInfo.getJobArea());
            statement.setString(4,jobInfo.getJobCompany());

            statement.setString(5,jobInfo.getJobSalary());

            statement.addBatch();
        }
        statement.executeBatch();

        statement.close();
        connection.close();
        return 0;
    }
}
